﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace QL_xxx
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private QLPhong_View qlPhong_view = null;
        private QLLoaiPhong_View qlLoaiPhong_view = null;
        private QLSanPham_View qlSanPham_view = null;
        private QLDatPhong_View qlDatPhong_view = null;
        private ThongTin_View thongTin_view = null;
        private QLBaoCao_View qlBaoCao_view = null;
        private QLQuyDinh qlQuyDinh = null;
        private enum VIEWTYPE
        {
            Phong, LoaiPhong, SanPham, DatPhong, ThongTin, BaoCao, QuyDinh
        }

        public MainWindow()
        {
            InitializeComponent();
        }

        private void btnThoat_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (MessageBoxResult.Yes == MessageBox.Show("Bạn có chắc muốn thoát?", "Thông báo.", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No))
                e.Cancel = false;
            else
                e.Cancel = true;
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            SwitchView(VIEWTYPE.Phong);


        }
        private void SwitchView(VIEWTYPE viewType)
        {
            GridViewForSwitchView.Children.Clear();
            switch (viewType)
            {
                case VIEWTYPE.Phong:
                    if (qlPhong_view == null)
                    {
                        qlPhong_view = new QLPhong_View();
                        qlPhong_view.Padding = new Thickness(0, 0, 0, 0);
                        qlPhong_view.Margin = new Thickness(0, 0, 0, 0);
                        qlPhong_view.SetValue(Grid.ColumnProperty, 0);
                        qlPhong_view.SetValue(Grid.RowProperty, 0);
                        qlPhong_view.SetValue(Grid.ColumnSpanProperty, 1);
                        qlPhong_view.SetValue(Grid.ColumnSpanProperty, 1);
                    }
                    GridViewForSwitchView.Children.Add(qlPhong_view);
                    break;

                case VIEWTYPE.LoaiPhong:
                    if (qlLoaiPhong_view == null)
                    {
                        qlLoaiPhong_view = new QLLoaiPhong_View();
                        qlLoaiPhong_view.Padding = new Thickness(0, 0, 0, 0);
                        qlLoaiPhong_view.Margin = new Thickness(0, 0, 0, 0);
                        qlLoaiPhong_view.SetValue(Grid.ColumnProperty, 0);
                        qlLoaiPhong_view.SetValue(Grid.RowProperty, 0);
                        qlLoaiPhong_view.SetValue(Grid.ColumnSpanProperty, 1);
                        qlLoaiPhong_view.SetValue(Grid.ColumnSpanProperty, 1);
                    }
                    GridViewForSwitchView.Children.Add(qlLoaiPhong_view);
                    break;
                case VIEWTYPE.SanPham:
                    if (qlSanPham_view == null)
                    {
                        qlSanPham_view = new QLSanPham_View();
                        qlSanPham_view.Padding = new Thickness(0, 0, 0, 0);
                        qlSanPham_view.Margin = new Thickness(0, 0, 0, 0);
                        qlSanPham_view.SetValue(Grid.ColumnProperty, 0);
                        qlSanPham_view.SetValue(Grid.RowProperty, 0);
                        qlSanPham_view.SetValue(Grid.ColumnSpanProperty, 1);
                        qlSanPham_view.SetValue(Grid.ColumnSpanProperty, 1);
                    }
                    GridViewForSwitchView.Children.Add(qlSanPham_view);
                    break;
                case VIEWTYPE.DatPhong:
                    if (qlDatPhong_view == null)
                    {
                        qlDatPhong_view = new QLDatPhong_View();
                        qlDatPhong_view.Padding = new Thickness(0, 0, 0, 0);
                        qlDatPhong_view.Margin = new Thickness(0, 0, 0, 0);
                        qlDatPhong_view.SetValue(Grid.ColumnProperty, 0);
                        qlDatPhong_view.SetValue(Grid.RowProperty, 0);
                        qlDatPhong_view.SetValue(Grid.ColumnSpanProperty, 1);
                        qlDatPhong_view.SetValue(Grid.ColumnSpanProperty, 1);
                    }
                    GridViewForSwitchView.Children.Add(qlDatPhong_view);
                    break;
                case VIEWTYPE.ThongTin:
                    if (thongTin_view == null)
                    {
                        thongTin_view = new ThongTin_View();
                        thongTin_view.Padding = new Thickness(0, 0, 0, 0);
                        thongTin_view.Margin = new Thickness(0, 0, 0, 0);
                        thongTin_view.SetValue(Grid.ColumnProperty, 0);
                        thongTin_view.SetValue(Grid.RowProperty, 0);
                        thongTin_view.SetValue(Grid.ColumnSpanProperty, 1);
                        thongTin_view.SetValue(Grid.ColumnSpanProperty, 1);
                    }
                    GridViewForSwitchView.Children.Add(thongTin_view);
                    break;
                case VIEWTYPE.BaoCao:
                    if (qlBaoCao_view == null)
                    {
                        qlBaoCao_view = new QLBaoCao_View();
                        qlBaoCao_view.Padding = new Thickness(0, 0, 0, 0);
                        qlBaoCao_view.Margin = new Thickness(0, 0, 0, 0);
                        qlBaoCao_view.SetValue(Grid.ColumnProperty, 0);
                        qlBaoCao_view.SetValue(Grid.RowProperty, 0);
                        qlBaoCao_view.SetValue(Grid.ColumnSpanProperty, 1);
                        qlBaoCao_view.SetValue(Grid.ColumnSpanProperty, 1);
                    }
                    GridViewForSwitchView.Children.Add(qlBaoCao_view);
                    break;
                case VIEWTYPE.QuyDinh:
                    if (qlQuyDinh == null)
                    {
                        qlQuyDinh = new QLQuyDinh();
                        qlQuyDinh.Padding = new Thickness(0, 0, 0, 0);
                        qlQuyDinh.Margin = new Thickness(0, 0, 0, 0);
                        qlQuyDinh.SetValue(Grid.ColumnProperty, 0);
                        qlQuyDinh.SetValue(Grid.RowProperty, 0);
                        qlQuyDinh.SetValue(Grid.ColumnSpanProperty, 1);
                        qlQuyDinh.SetValue(Grid.ColumnSpanProperty, 1);
                    }
                    GridViewForSwitchView.Children.Add(qlQuyDinh);
                    break;
                default:
                    break;
            }
        }

        private void btnQuanLyLoaiPhong_Click(object sender, RoutedEventArgs e)
        {
            SwitchView(VIEWTYPE.LoaiPhong);
        }

        private void btnQuanLyPhong_Click(object sender, RoutedEventArgs e)
        {
            SwitchView(VIEWTYPE.Phong);
        }

        private void btnQuanLySanPham_Click(object sender, RoutedEventArgs e)
        {
            SwitchView(VIEWTYPE.SanPham);
        }

        private void btnPhieuDatPhong_Click(object sender, RoutedEventArgs e)
        {
            SwitchView(VIEWTYPE.DatPhong);
        }


        private void btnAbout_Click(object sender, RoutedEventArgs e)
        {
            SwitchView(VIEWTYPE.ThongTin);
        }

        private void btnBaoCao_Click(object sender, RoutedEventArgs e)
        {
            SwitchView(VIEWTYPE.BaoCao);
        }

        private void btnQuyDinh_Click(object sender, RoutedEventArgs e)
        {
            SwitchView(VIEWTYPE.QuyDinh);
        }
    }
}
